package com.bluegalaxy.sitescore.controller;

import com.baomidou.mybatisplus.plugins.Page;
import com.bluegalaxy.sitescore.entity.TbSiteInfo;
import com.bluegalaxy.sitescore.service.ITbSiteInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/11/26 0026.
 */
@Controller
@RequestMapping("/siteView")
public class SiteViewController  extends BaseController  {
    @Autowired
    private ITbSiteInfoService siteInfoService;

    @com.baomidou.kisso.annotation.Permission("1001")
    @RequestMapping("/view")
    public String view(Model model) {
        List<TbSiteInfo> tbSiteInfoList = siteInfoService.getSiteInfoAll();
        //model.addAttribute("province",province);
      //  model.addAttribute("city",city);
      //  model.addAttribute("dist",dist);
      //  System.out.println(tbSiteInfoList.get(0).getCity());
        model.addAttribute("siteList",toJson(tbSiteInfoList));
        return "/site/view";
    }

    @com.baomidou.kisso.annotation.Permission("1001")
    @RequestMapping("/list")
    public String list(Model model,String province,String city,String dist) {
        model.addAttribute("province", province);
        model.addAttribute("city", city);
        model.addAttribute("dist",dist);
        return "/site/list";
    }
    @ResponseBody
    @com.baomidou.kisso.annotation.Permission("1001")
    @RequestMapping("/getSiteInList")
    public String getSiteInList(String province,String city,String dist) {
        Page<TbSiteInfo> page = getPage();
        return jsonPage(siteInfoService.getSiteInfoList(page,province,city));
    }
}
